package com.ly.lytestbootkotlin.controller

import com.ly.lytestbootkotlin.domain.Result
import com.ly.lytestbootkotlin.service.IUserService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/user")
class UserController {

    @Qualifier("userServiceImpl")
    @Autowired
    private lateinit var userService: IUserService

    @GetMapping("/list")
    fun getUsers(): Result{
//        return Result.ok("傻子")
        return userService.getUsers()
    }

    @GetMapping("/one/{id}")
    fun getUser(@PathVariable("id") id:Long):Result{
        return userService.getUser(id)
    }

}